<template>
    <div class="main-container">
        <div class="vertical-line" title="垂直线"></div>
        <div class="horizontal-line" title="水平线"></div>
        <div class="demo"></div>
    </div>
</template>

<script>
export default {
    // 各种实现垂直居中的方法
    name: 'vertical_and_center'
}
</script>

<style lang="scss" scoped>
    .main-container {
        position: absolute;
        background-color: red;
        width: 500px;
        height: 500px;
        .demo {
            position: relative;
            background-color: green;
            width: 200px;
            height: 200px;
            margin: 0 auto;
            top: 50%;
            transform: translateY(-50%);
        }
        .vertical-line {
            position: absolute;
            background-color: black;
            width: 1px;
            height: 500px;
            left: 50%;
        }
        .horizontal-line {
            position: absolute;
            background-color: black;
            width: 500px;
            height: 1px;
            top: 50%;
        }
    }
</style>